using UnityEngine;
using QFramework;
using QAssetBundle;

// 1.请在菜单 编辑器扩展/Namespace Settings 里设置命名空间
// 2.命名空间更改后，生成代码之后，需要把逻辑代码文件（非 Designer）的命名空间手动更改
namespace QFramework.Example
{
    public partial class Bomb : ViewController
    {
        void Start()
        {
            // Code Here
        }

        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.GetComponent<CollectableArea>())
            {
                AudioKit.PlaySound(Sfx.BOMB);
                CamareController.Default.CamareShake();
                var floattingText = FindObjectOfType<FloattingTextController>();
                var enemys = FindObjectsByType<Enemy>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
                foreach (var item in enemys)
                {
                    if (item != null)
                    {
                        floattingText.OnPlay(item.transform.position + item.transform.up * 0.5f, Mathf.Abs(item.OnGetCurrentEnemyHp()).ToString());
                        item?.OnSetHp(-item.OnGetCurrentEnemyHp());
                    }
                }
                gameObject.DestroySelfGracefully();
            }
        }
    }
}
